/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 有点呆
 * Date: 2024-07-09
 * Time: 22:31
 */

public class Task {

//    2，数字符串中单词个数
    public static int countSegments(String s) {
        if(s.length() == 0){
            return 0;
        }
        String[] ret = s.split(" ");
        int count = 0;
        for(String x : ret){
            if(x.length() != 0){
                count++;
            }
        }
        return count;
    }

//    1，将字符串中的大写字母转为小写字母
        public  static String toLowerCase(String s) {
            StringBuilder sbui = new StringBuilder();
            for(int i = 0;i < s.length();i++){
                char ch = s.charAt(i);//获取第i个位置的字符
                //判断这个字符是不是字母
                if(Character.isLetter(ch)){
                    //如果是大写字母，转小写
                    if(!Character.isLowerCase(ch)){
                        ch = (char)(ch+32);
                    }
                }
                sbui.append(ch);
            }
            return sbui.toString();
        }

    public static void main(String[] args) {

    }
}


